package com.trans.service.impl;

import com.trans.dao.AccountDao;
import com.trans.service.AccountService;
import com.trans.service.LogService;
import javafx.beans.binding.DoubleExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.FileNotFoundException;
import java.io.IOException;

@Service
//
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;


    @Autowired
    private LogService logService;

    /**
     */
    @Transactional
    public void zhuanzhang(String fromName, String toName, Double money) throws IOException{
        try {
            accountDao.addMoney(toName,money);
            int i = 10/0;
            accountDao.minusMoney(fromName,money);
        }finally {
            //不管转账成功还是失败，都需要写入日志信息
            logService.writeLog(fromName,toName,money);
        }


    }
}
